// JavaScript Document
/** ************************** */
var NEWS_INDEX = 1, CASE_INDEX = 3, PRODUCT_INDEX = 2, PRODUCT_SERVICE_INDEX = 6, ABOUT_INDEX = 4, CONTACT_INDEX = 5, HOME_INDEX = -1;
var jsReady = false;
var swfReady = false;
var isPosition = false;

function isReady() {
	return jsReady;
}

function setSwfReady() {
	swfReady = true;
	if(!isPosition) {
		getSwf("nav_flash").setPosition(pageIndex);
	}
}

function pageInit() {
	jsReady = true;
}

function getSwf(swfName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[swfName];
	} else {
		if (document.embeds && document.embeds[swfName]) {
		    return document.embeds[swfName];
		} else {
		    return document.getElementById(swfName);
		}
	}
}

function openUrl(index) {
	switch (parseInt(index)) {
	case NEWS_INDEX:
		window.open(ctx + "/pages/web/news/newsList.jsp", "main");
		break;
	case CASE_INDEX:
		window.open(ctx + "/pages/web/case/case.jsp", "main");
		break;
	case PRODUCT_INDEX:
		window.open(ctx + "/pages/web/product/product.jsp?categoryType=1", "main");
		break;
	case PRODUCT_SERVICE_INDEX:
		window.open(ctx + "/pages/web/product/product.jsp?categoryType=0", "main");
		break;
	case ABOUT_INDEX:
		window.open(ctx + "/company/web/getAboutUs.do?languageId=" + language + "&flag=1", "main");
		break;
	case CONTACT_INDEX:
		window.open(ctx + "/company/web/getAboutUs.do?languageId=" + language + "&flag=0", "main");
		break;
	case HOME_INDEX:
		window.open(ctx + "/pages/web/index.jsp", "_self");
		break;
	default:
		break;
	}

}
$(document).ready(function(e) {
	openUrl(pageIndex);
	$("#main_iframe").one("load", function(e) {
		 if (swfReady) {
			 getSwf("nav_flash").setPosition(pageIndex);
			 isPosition = true;
		 }
	});
});